package com.example.study.state;

public class Context {

    private State state = new CloseState();// 默认状态

    private String id;

    public Context(String id) {
        this.id = id;
    }

    public void setState(State state) {
        this.state = state;
    }

    public void startSession() {
        state.startSession(this); // 开始
    }

    public String writeAndGet() {
        return state.writeAndGet(this);

    };// 写入获取结果

    public void endSession() {
        state.endSession(this);
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(String id) {
        this.id = id;
    };
}